strs=['dlower','flow','flight']

def longestCommonPrefix(strs):
    common_prefix=strs[0]
    i=1
    while i<len(strs):
        j,k=0,0
        strs_elem=strs[i]
        while j<len(common_prefix) and k<len(strs[i]):
            if common_prefix[j]==strs_elem[k]:
                j+=1
                k+=1
                continue
            else:
                break
        if j==0 and common_prefix[j]!=strs_elem[j]:
            return ""
        else:
            common_prefix=common_prefix[:j]
            i+=1
    return common_prefix
print(longestCommonPrefix(strs))